"""
n为正整数，满足下面算法：
n偶数，n=n/2
n奇数，n=3n+1
寻找在100万以内的数字满足的最长循环，起始数字多少
"""
dic = {2: 1}
ls = []
for n in range(13, 14):
    count = 0
    i = n
    while 1:
        if i == 1:
            break
        count += 1
        if i % 2 == 0:
            i = i/2
        else:
            i = 3*i+1
    if count > list(dic.values())[0]:
        dic = {n: count}
    elif count == list(dic.values())[0]:
        ls.append({n: count})
print(dic)
print(ls)